<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
<%
    String path = request.getContextPath();
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Expires", "0");

    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>品牌库管理</title>
<link rel="stylesheet" type="text/css"
    href="<%=basePath%>/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
    href="<%=basePath%>/js/easyui/themes/icon.css">
<link href="<%=basePath%>/js/uploadify/uploadify.css" type="text/css" rel="stylesheet" />   
<script type="text/javascript" src="<%=basePath%>/js/easyui/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>

<style type="text/css">
    .td {
        text-align: right;
        background: #E0ECF8;
    }

    TD {
        FONT-SIZE: 13px;
        FONT-FAMILY: arial;
        nowrap: true;
    }

    table {
        BORDER-COLLAPSE: collapse
    }
</style>
<link rel="stylesheet" href="<%=basePath%>/editor/themes/default/default.css" />
<link rel="stylesheet" href="<%=basePath%>/editor/plugins/code/prettify.css" />
<script charset="utf-8" src="<%=basePath%>/editor/kindeditor.js"></script>
<script charset="utf-8" src="<%=basePath%>/editor/lang/zh_CN.js"></script>
<script>
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('#editor1',{
            uploadJson: '/ke/upload.action',
            /*fileManagerJson: '/editor/jsp/file_manager_json.jsp',*/
            fileManagerJson: '/ke/browsePictures.action',
          /*  pagebreakHtml: '<div style="page-break-after: always;"><span style="display: none;">&nbsp;</span></div>',*/
            allowFileManager: 'true'
        });
    });
</script>
<script>
function save() {
	editor.sync();
	$("#industryIds").val($('#industriesCombo').combotree('getValues'));
	$("#districtId").val($('#districtsCombo').combotree('getValues'));
    $("#brandForm").submit();    
}

$(function() {
    $("#logoFile").uploadify({
        'uploader': '../../js/uploadify/uploadify.swf',
        'script': 'add_logo.action',
        'cancelImg': '../../js/uploadify/cancel.png',
        'scriptData' : {
            'brandForm.id' : $('#brandFormId').val()
        },
        'folder': '../../brand/logo/',
        'fileDataName' : 'uploadify',
        'auto': true,
        'multi': false,
        'onComplete' : function(event, ID, fileObj, response, data) {
            var dataObj = eval("(" + response + ")");
            $('#brandFormLogoImg').attr("src", '../../brand/logo/' + dataObj);
            $('#brandFormLogo').val(dataObj);
        }
    });
    $("#figureImageFile").uploadify({
        'uploader': '../../js/uploadify/uploadify.swf',
        'script': 'add_figure_image.action',
        'cancelImg': '../../js/uploadify/cancel.png',
        'scriptData' : {
            'brandForm.id' : $('#brandFormId').val()
        },
        'folder': '../../brand/figure/',
        'fileDataName' : 'uploadify',
        'auto': true,
        'multi': false,
        'onComplete' : function(event, ID, fileObj, response, data) {
            var dataObj = eval("(" + response + ")");
            $('#brandFormFigureImg').attr("src", '../../brand/figure/' + dataObj);
            $('#brandFormFigureImage').val(dataObj);
        }
    });
    var industryIds = $("#industryIds").attr("value");
    if (industryIds) {
        var t = [];
        t = industryIds.split(",");
        $('#industriesCombo').combotree('setValues', t);
    }
    var districtId = $("#districtId").attr("value");
    if (districtId) {
    	var t = [];
        t = districtId.split(",");
        $('#districtsCombo').combotree('setValues', t);
    }
});    
</script>
</head>
<body>

<body class="easyui-layout">
<div region="center" style="height:900px;padding:10px;background:#efefef;">
    <div id="brand-center" class="easyui-tabs" fit="true" border="false">
        <div id="p" title="编辑品牌" style="height:1100px;padding:20px;">
            <form id="brandForm" action="add_or_update_brand.action" method="post"
                  enctype="multipart/form-data">
                <table border="1" width="100%">  
                	<tr>
                        <td><label>LOGO</label></td>
                        <td>
                        	<input type="hidden" id="brandFormLogo" name="brandForm.logo"
                                   value="${brandForm.logo}"/>
   							<input id="logoFile" name="logoFile" type="file"/>                                
                            <img id="brandFormLogoImg" name="brandForm.logo" width="100px" height="100px" src="../../brand/logo/${brandForm.logo}"/>
                        </td>
                    </tr>
                    <tr>
                        <td><label>形象图片</label></td>
                        <td>
                        	<input type="hidden" id="brandFormFigureImage" name="brandForm.figureImage"
                                   value="${brandForm.figureImage}"/>
   							<input id="figureImageFile" name="figureImageFile" type="file"/>                                
                            <img id="brandFormFigureImg" name="brandForm.figureImage" width="100px" height="100px" src="../../brand/figure/${brandForm.figureImage}"/>
                        </td>
                    </tr>          	
                    <tr>
                        <td><label>英文标题</label></td>
                        <td>
                            <input name="brandForm.enTitle" class="easyui-validatebox" size=45 value="${brandForm.enTitle}">
                        </td>
                    </tr>
                    <tr>
                        <td><label>中文标题</label></td>
                        <td>
                            <input name="brandForm.cnTitle" class="easyui-validatebox" size="45" value="${brandForm.cnTitle}">
                        </td>
                    </tr>
                    <tr>
                        <td><label>页面标题</label></td>
                        <td>
                            <input name="brandForm.metaDescription" class="easyui-validatebox" size="45" value="${brandForm.metaDescription}">
                        </td>
                    </tr>
                    <tr>
		                <td><label>栏目关联</label></td>
		                <td>
		                    <select id="industriesCombo" class="easyui-combotree" 
		                            url="fetch_industries.action"
		                            multiple="true" cascadeCheck="false" style="width:300px;"></select>
		                </td>
		            </tr>
		            <tr>
		                <td><label>地区</label></td>
		                <td>
		                    <select id="districtsCombo" class="easyui-combotree" 
		                            url="fetch_districts.action"
		                            style="width:300px;"></select>
		                </td>
		            </tr>
                    <tr>
                        <td><label>优先级</label></td>
                        <td>
                            <input name="brandForm.priority" class="easyui-validatebox" size=45
                                   value="${brandForm.priority}">
                        </td>
                    </tr>
                    <tr>
                        <td><label>创始人</label></td>
                        <td>
                            <input name="brandForm.founder" class="easyui-validatebox" size=45 value="${brandForm.founder}">

                        </td>
                    </tr>
                    <tr>
                        <td><label>发源地</label></td>
                        <td>
                            <input name="brandForm.birthland" class="easyui-validatebox" size=45 value="${brandForm.birthland}">

                        </td>
                    </tr>
                    <tr>
                        <td><label>品牌主页</label></td>
                        <td>
                            <input name="brandForm.website" class="easyui-validatebox" size=45 value="${brandForm.website}">

                        </td>
                    </tr>
                    <tr>
                        <td><label>隶属公司</label></td>
                        <td>
                            <input name="brandForm.company" class="easyui-validatebox" size=45 value="${brandForm.company}">

                        </td>
                    </tr>
                    <tr>
                        <td><label>产品线</label></td>
                        <td>
                            <input name="brandForm.product" class="easyui-validatebox" size=45 value="${brandForm.product}">
                        </td>
                    </tr>
                    <tr>
                        <td><label>品牌介绍</label></td>
                        <td>
                            <textarea class="easyui-validatebox" cols="80" rows="5"
								name="brandForm.introduction" ><s:property value ="brandForm.introduction"/></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td><label>附加说明</label></td>
                        <td>
                            <!--  FCK:editor instanceName="default" inputName="brandForm.additionalText" width="100%" height="800"
                                        value="${brandForm.additionalText}" toolbarSet="Default"/-->
                            <textarea id="editor1" name="brandForm.additionalText" style="width:100%;height:900px;visibility:hidden;">${brandForm.additionalText}</textarea>            
                        </td>
                    </tr>
                    
                    <tr>
                        <td align="center" colspan="2">
                            <a class="easyui-linkbutton" onClick="save()">保存</a>
                            <a class="easyui-linkbutton" onClick="javascript:history.back()">取消</a>
                        </td>
                    </tr>
                    
                </table>
                <input type="hidden" id="industryIds" name="industryIds" value="<s:property value ="industryIds"/>"/>
                <input type="hidden" id="districtId" name="brandForm.district.id" value="<s:property value ="brandForm.district.id"/>"/>
                <input type="hidden" id="brandFormId" name="brandForm.id" value="<s:property value ="brandForm.id"/>"></input>
            </form>
        </div>
    </div>
</div>

</body>
</html>